from django.db import models

# Create your models here.
class Users(models.Model):
    username=models.CharField(max_length=24,verbose_name='用户名')
    password=models.CharField(max_length=24,verbose_name='密码')
    code=models.CharField(max_length=24,verbose_name='邀请码')
    rec_code=models.CharField(max_length=8,verbose_name='推荐码')
    totle=models.DecimalField(max_digits=10,decimal_places=2,verbose_name='金额')
    class Meta:
        db_table='users'
        verbose_name='用户表'
        verbose_name_plural=verbose_name
    def __str__(self):
        return self.username

class Goods(models.Model):
    goodname=models.CharField(max_length=24,verbose_name='商品名')
    price=models.DecimalField(max_digits=10,decimal_places=2,verbose_name='价格')
    class Meta:
        db_table='goods'
        verbose_name='商品表'
        verbose_name_plural=verbose_name
    def __str__(self):
        return self.goodname

class Orders(models.Model):
    goods=models.ForeignKey(Goods,on_delete=models.CASCADE,verbose_name='所属商品')
    user=models.ForeignKey(Users,on_delete=models.CASCADE,verbose_name='所属用户')
    count=models.IntegerField(default=20,verbose_name='数量')
    price=models.DecimalField(max_digits=10,decimal_places=2,verbose_name='产品单价')
    total_price=models.DecimalField(max_digits=10,decimal_places=2,verbose_name='产品总价')
    status=models.IntegerField(choices=((1,'待发货'),(2,'待收货')))
    class Meta:
        db_table='orders'
        verbose_name='订单表'
        verbose_name_plural=verbose_name
    def __str__(self):
        return self.goods

